package br.com.colegio.dao;

import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import br.com.colegio.dao.storage.Storage;

public class FinanceiroLancamentoDAO {/*
	public static Collection<Object> list(){
		try {
			return Storage.select(FinanceiroLancamento.class.getName(),null);
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}

	public static FinanceiroLancamento get(Long cod){
		try {
			Object r = Storage.get(FinanceiroLancamento.class.getName(),cod);
			if(r != null) return (FinanceiroLancamento)r;
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}

	public static Collection<Object> getByData(Date dIni, Date dFim){
		return getByContaAndData(null, dIni, dFim);
	}

	public static Collection<Object> getByContaAndData(String conta, Date dIni, Date dFim){
		try {
			String params = "String p1, String p2, String p3";
			String filter = "";

			if(conta != null) filter = "conta = p1";
			if(dIni != null && !filter.equals("")) filter = "&& data >= p2";
			else filter = "data >= p2";

			if(dFim != null && !filter.equals("")) filter = "&& data < p3";
			else filter = "data < p3";

			Map<String,Object> parVal = new HashMap<String,Object>();
			parVal.put("p1",conta);
			parVal.put("p2",dIni);
			parVal.put("p3",dFim);

			return Storage.select(FinanceiroLancamento.class.getName(),filter,params,parVal,null);
		}
		catch(Exception e){
			e.printStackTrace();
		}
		return null;
	}

	public static FinanceiroLancamento save(FinanceiroLancamento reg) throws Exception {
		return (FinanceiroLancamento)Storage.save(reg);
	}

	public static void delete(Long reg) throws Exception {
		Storage.delete(FinanceiroLancamento.class.getName(), reg);
	}*/
}
